<template>
    <div class="common-layout">
        <el-container class="container">
            <el-header>
                <div class="header">
                    <div class="title">问卷调查系统</div>
                    <div>
                        <el-dropdown>
                            <span class="el-dropdown-link" style="color: #fff;">
                                admin<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>
                            <template #dropdown>
                                <el-dropdown-menu>
                                    <el-dropdown-item>个人信息</el-dropdown-item>
                                    <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                                </el-dropdown-menu>
                            </template>
                        </el-dropdown>
                    </div>
                </div>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <el-menu :default-active="$route.path" class="el-menu-vertical-demo" style="height: 100%;"
                        @open="handleOpen" @close="handleClose" router>
                        <el-menu-item index="/front">首页</el-menu-item>
                        <el-sub-menu>
                            <template index="1" #title>
                                <span>信息管理</span>
                            </template>
                            <el-menu-item-group>
                                <el-menu-item index="/wjxx">问卷信息</el-menu-item>
                                <el-menu-item index="/tmxx">题目信息</el-menu-item>
                                <el-menu-item index="/ffjl">问答记录</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>
                    </el-menu>
                </el-aside>
                <el-main>
                    <RouterView></RouterView>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>
<script setup>
import { ElMessage } from 'element-plus';
import service from '../request/Request';
import router from '../router';


const logout = async () => {
    const res = await service.get("/logout")
    if (res.code == 200) {
        ElMessage({
            type: "success",
            message: "成功"
        })
        router.push("/")
    }

}


</script>
<style>
.common-layout {
    width: 100%;
    height: 100%;
}

.container {
    width: 100%;
    height: 100%;
}

.header {
    width: 100%;
    height: 100%;
    background: #817a70;
    display: flex;
    padding: 0px 20px;
    align-items: center;
    box-sizing: border-box;
    justify-content: space-between;
}

.el-header {
    padding-left: 0px !important;
    padding-right: 0px !important;
}

.el-dropdown-link {
    outline: none !important;
}

.title {
    font-size: 20px;
    font-weight: bold;
    color: #ffff;
}
</style>